# Figure B.4: Average Net Benefit by Ballot Position


# 1. Load Packages ----

library(tidyverse)

# 2. Read in Data ----

load(file = "df_voxit_prop_canton.RData")

# 3. Data Preparation ----
summary_prop_ca <- voxit_prop_canton %>%
  group_by(prop_nr_day) %>%
  summarise(net_bnefit_avg = mean(net_benefit),
            obs = n(),
            nb_se = sd(net_benefit)/sqrt(n())) %>%
  mutate(ci_95 = nb_se*1.96)

# 4. Create Graph ----
ggplot(data = summary_prop_ca, mapping = aes(x = prop_nr_day, y = net_bnefit_avg)) +
  geom_point() +
  geom_errorbar(mapping = aes(ymin = net_bnefit_avg-ci_95, ymax = net_bnefit_avg+ci_95),
                width = 0.1) +
  scale_y_continuous(name = "Average net benefit") +
  scale_x_continuous(name = "Ballot position",
                     limits = c(.95,6.05),
                     breaks = seq(1,6,1),
                     labels = seq(1,6,1)) +
  theme_bw(base_size = 13)

# 5. Save Graph ----
ggsave(filename = "FigureB4.pdf", width = 9.35, height = 6.28)
